package cn.ly.easymocktest;

import org.easymock.EasyMockRule;
import org.easymock.EasyMockSupport;
import org.easymock.Mock;
import org.easymock.TestSubject;
import org.junit.Rule;
import org.junit.Test;

import static org.easymock.EasyMock.expect;

/**
 * Created by liuyu21 on 2017/10/21.
 */
public class MainTest extends EasyMockSupport{

    @Rule
    public EasyMockRule mocks = new EasyMockRule(this);

    @TestSubject
    private MockHelloUnderTest mockHelloUnderTest = new MockHelloUnderTest();

    @Mock
    private MockHelloImpl mock;

    @Test
    public void testSayHello(){
        mock.sayHello("ly");
        replayAll();
        mockHelloUnderTest.testSayHello("ly");
        verifyAll();
    }

    @Test
    public void testAdd(){
        int a = 1, b = 1, result = 2;
        expect(mock.add(a,b)).andReturn(result);
        replayAll();
        mockHelloUnderTest.testAdd(a,b,result);
        verifyAll();
    }
}
